<template>
  <el-row>
    <el-col>
      <el-row >
        <el-col :span="2">
          <el-button class="dc_b" type="primary" round size="mini" @click="dc_click">导出</el-button>
        </el-col>
        <el-col :span="2" >
          <el-select v-model="value2" placeholder="筛选镇街" clearable @change="getVisit" v-if="street_id">
            <el-option v-for="item in options2" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-col>
      </el-row>
    </el-col>
    <el-col class="table_c">
      <el-table @row-click="tableclick" :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="tableData.list"
        style="width: 100%">
        <el-table-column prop="rank" label="排名" width="50">
        </el-table-column>
        <el-table-column prop="company_name" label="企业名称" width="300">
        </el-table-column>
        <el-table-column prop="project" label="预警项目" width="120">
          <template slot-scope="scope">
            <div class="text_padding" v-if="scope.row.t1 == 1">
              <span class="pj_div">未入前30</span>
            </div>
            <div class="text_padding" v-if="scope.row.t2 == 1">
              <span class="pj_div">退出前30</span>
            </div>
            <div class="text_padding" v-if="scope.row.t3 == 1">
              <span class="pj_div">发明异常</span>
            </div>
            <div class="text_padding" v-if="scope.row.t4 == 1">
              <span class="pj_div">发明过低</span>
            </div>
            <div class="text_padding" v-if="scope.row.t5 == 1">
              <span class="pj_div">发明下降</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="reason" label="预警原因" width="470">
          <template slot-scope="scope">
            <div class="text_padding" v-if="scope.row.t1 == 1">
              优势企业、专利奖企业不在总量top30榜企业
            </div>
            <div class="text_padding" v-if="scope.row.t2 == 1">
              退出镇街总量排名前30企业（曾经进过前30）
            </div>
            <div class="text_padding" v-if="scope.row.t3 == 1" style="line-height:23px">
              镇街总量排名前100企业、优势企业、专利奖企业中，公司名带“科技”“信息”“技术”，发明授权专利为0的企业
            </div>
            <div class="text_padding" v-if="scope.row.t4 == 1" style="line-height:23px">
              镇街总量排名前100企业、优势企业、专利奖企业中，授权发明专利与实用新型比例低于1:8的企业
            </div>
            <div class="text_padding" v-if="scope.row.t5 == 1" style="line-height:23px">
              镇街总量排名前100企业、优势企业中，授权发明最近连续三年持续降低的企业。
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="remarks" label="备注" width="80">
          <template slot-scope="scope">
            <div class="text_margin">
              总量
            </div>
            <div class="text_margin">
              发明
            </div>
            <div class="text_margin">
              实用新型
            </div>
            <div class="text_margin">
              外观设计
            </div>
          </template>
        </el-table-column>


        <el-table-column prop="patent21" :label="tableData.date[0] + '年专利'">
          <template slot-scope="scope">
            <div class="text_blue text_margin">
              {{ scope.row.a_num }}
            </div>
            <div class="text_margin">
              {{ scope.row.a_agent }}
            </div>
            <div class="text_margin">
              {{ scope.row.a_news }}
            </div>
            <div class="text_margin">
              {{ scope.row.a_apper }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="patent20" :label="tableData.date[1] + '年专利'">
          <template slot-scope="scope">
            <div class="text_blue text_margin">
              {{ scope.row.b_num }}
            </div>
            <div class="text_margin">
              {{ scope.row.b_agent }}
            </div>
            <div class="text_margin">
              {{ scope.row.b_news }}
            </div>
            <div class="text_margin">
              {{ scope.row.b_apper }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="patent19" :label="tableData.date[2] + '年专利'">
          <template slot-scope="scope">
            <div class="text_blue text_margin">
              {{ scope.row.c_num }}
            </div>
            <div class="text_margin">
              {{ scope.row.c_agent }}
            </div>
            <div class="text_margin">
              {{ scope.row.c_news }}
            </div>
            <div class="text_margin">
              {{ scope.row.c_apper }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="140">
          <template slot-scope="scope">
            <el-button class="add_button" @click="handleClick(scope.row)" size="mini" round>添加到待走访</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-col>

    <el-dialog title="导出" :visible.sync="dialogVisible" width="30%" close="output_dialog">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="街道" class="form_street">
          <el-select v-model="form.region" placeholder="">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预警项目" class="form_project">
          <el-select v-model="form.region" placeholder="">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="时间" class="form_date">
          <el-date-picker ref="picker_d" type="date" placeholder="" v-model="form.date1"></el-date-picker>
        </el-form-item>
        <el-form-item class="form_button">
          <el-button type="primary" @click="onSubmit">确认导出</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </el-row>
</template>

<script>
import { companyStreet,visitDetailtwo } from '@/api/newuser'

export default {
  components: {},
  props: {
    activeName: {
      type: String
    },
    tableData: {
      type: Object,
    }
  },

  data() {
    return {
      search: '',
      dialogVisible: false,
      form: {
        region: '',
        date1: '',
        date2: '',
      },
      value2: '',
      options2: [],
      street_id: false
    };
  },
  mounted() {
    if (this.$store.state.user.com_id == 0 && this.$store.state.user.street_id == 0) {
      this.street_id = true
      companyStreet().then(res => {
        this.options2 = res;
        // console.log(res);
      })
    }
  },
  methods: {
    getVisit(street_type){
      this.$emit('getVisit',street_type)
    },
    onSubmit() {
      this.dialogVisible = false
      // console.log('submit!');
    },
    handleClick(row) {
      // console.log(row);
      this.$router.push(
        {
          path: '/addWaitvisit',
          query: {
            company_name: row.company_name,
            company_id: row.company_id,
          }
        }
      )
    },
    tableclick(row) {

      this.$router.push({
        path: '/workEnterprisevisit',
        query: {
          company_id: row.company_id,
          company_name: row.company_name,
        }
      })

      //判断是否有走访记录
      // visitDetailtwo({
      //   company_id: row.company_id
      // }).then(res => {
      //   // console.log(res);
      //   if (res.list.length == 0) {
      //     this.$router.push(
      //       {
      //         path: '/addWaitvisit',
      //         query: {
      //           company_name: row.company_name,
      //           company_id: row.company_id,
      //         }
      //       }
      //     )
      //   } else {
      //     this.$router.push({
      //       path: '/workEnterprisevisit',
      //       query: {
      //         company_id: row.company_id,
      //       }
      //     })
      //   }
      // })
      // this.$router.push({
      //   path: '/workEnterprisevisit',
      //   query: {
      //     company_id: row.company_id,
      //   }
      // })
    },
    TabsClick() {
    },
    dc_click() {
      // this.dialogVisible = true
      // setTimeout(() => {
      //   let dom_pre = document.getElementsByClassName('.el-input__prefix')
      //   // console.log(dom_pre);
      // }, 0);
      // el-input__prefix
      // el-input__suffix
      this.$emit('warningExport')
    }
  },
};
</script>

<style scoped lang="less">
::v-deep input {
  border-radius: 30px;
  height: 30px;
  line-height: 30px;
}

::v-deep .el-input__icon {
  line-height: 38px;
  font-size: 16px;
}

::v-deep .el-dialog__header {
  .el-dialog__title {
    font-size: 24px;
    font-weight: bolder;
  }

  button {
    position: absolute;
    top: -40px;
    left: 580px;
    font-size: 30px;

    i {
      border: 2px solid #fff;
      border-radius: 30px;
      color: #fff;
    }
  }

  button:hover {
    i {
      border: 2px solid #409EFF;
    }
  }
}

::v-deep .el-dialog__body {
  .el-form {
    .el-form-item {

      .el-form-item__label {
        color: #334681;
        font-size: 16px;
        font-weight: initial;
      }
    }
  }
}

::v-deep .form_street .el-form-item__content .el-select,
::v-deep .form_project .el-form-item__content .el-select,
::v-deep .form_date .el-form-item__content .el-date-editor {
  width: 100%;
  line-height: 38px;
}

::v-deep .form_street .el-form-item__content .el-select input,
::v-deep .form_project .el-form-item__content .el-select input,
::v-deep .form_date .el-form-item__content .el-date-editor input {
  border-radius: 5px;
  height: 38px;
  line-height: 38px;
}

::v-deep .form_street .el-form-item__label,
::v-deep .form_project .el-form-item__label,
::v-deep .form_date .el-form-item__label {
  text-align: initial;
}

::v-deep .form_button .el-form-item__content {
  margin: 10px 0;
  float: right;
}

.form_button {
  margin-bottom: 0px;
}

::v-deep .form_button .el-form-item__content .el-button {
  padding: 8px 25px;
  width: 139px;
  height: 38px;
  background: #387DFF;
  border: 1px solid #E8ECEF;
  border-radius: 19px;
}

.dc_b {
  width: 124px;
  height: 38px;
  background: #387DFF;
  border-radius: 19px;
  font-size: 16px;
}

.el-main {
  margin-right: 15px;
  border-radius: 5px;
  margin: 25px 30px 0 30px;
}

.table_c {
  margin-top: 15px;
}

.add_button {
  color: #3E7EF5;
  background-color: #ecf3ff;
  border: none;
  font-size: 14px;
}

::v-deep .has-gutter tr th {
  font-size: 10px;
  font-weight: initial;
}

::v-deep tbody tr td:nth-child(5),
::v-deep tbody tr td:nth-child(6),
::v-deep tbody tr td:nth-child(7),
::v-deep tbody tr td:nth-child(8),
::v-deep tbody tr td:nth-child(9) {
  text-align: center;
}

::v-deep thead tr th:nth-child(5),
::v-deep thead tr th:nth-child(6),
::v-deep thead tr th:nth-child(7),
::v-deep thead tr th:nth-child(8),
::v-deep thead tr th:nth-child(9) {
  text-align: center;
}

::v-deep .has-gutter tr th:nth-child(11) {
  text-align: center;
}

.text_margin {
  margin: 10px 0;
}

.text_padding {
  padding: 10px 0;
}

// :v-deep .has-gutter tr th:last-child {
//   text-align: center;
// }
::v-deep .el-table__row td {
  font-size: 10px;
}

::v-deep .el-table__row td:nth-child(3) .cell {
  // height: 90px;
  line-height: 45px;
  padding: 0;
}

::v-deep .el-table__row td:nth-child(4) .cell {
  // height: 90px;
  line-height: 45px;
  padding: 0;
}

::v-deep .el-table__row td:nth-child(3) .cell div:nth-child(1) {
  border-bottom: 1px solid #EBEEF5;
}

::v-deep .el-table__row td:nth-child(4) .cell div:nth-child(1) {
  border-bottom: 1px solid #EBEEF5;
}

.pj_div {
  color: #fff;
  background-color: #FF5F58;
  padding: 4px;
  border-radius: 5px;
}

.text_blue {
  color: #387DFF;
}

@media (max-width: 1360px) {}

@media (max-width: 1280px) {}
</style>
